package com.teamwork.module01.controller;


import com.alibaba.fastjson.JSON;
import com.teamwork.common.entity.User;
import com.teamwork.module01.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    private  static final Logger logger = LoggerFactory.getLogger(UserController.class);
    @Autowired
    private UserService userService;

    @GetMapping("/{id}")
    public String getone(@PathVariable("id") Long id){
        User user = userService.getone(id);
        logger.info("查询一条用户记录:"+user);

        String s = JSON.toJSONString(user);
        return s;

    }

}
